package edu.zut.main.thread;

public class ThreadSleep {

    public static void main(String[] args) {
        CountDown countDown = new CountDown();
        new Thread(countDown).start();
    }

}
//线程休眠模拟倒计时
class CountDown implements Runnable{

    private int num = 10;

    //倒计时任务
    @Override
    public void run() {
        while (true){
            System.out.println(num--);
            //每间隔1s执行一次
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (num <= 0){
                break;
            }
        }

    }
}